﻿<Window x:Class="Hp.Vertica.Client.SqlConnection"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clr-namespace:Hp.Vertica.Client"
        Title="SqlConnection" Height="210" Width="400" WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="2"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="25"/>
        </Grid.RowDefinitions>
        <ProgressBar Grid.Row="0" IsIndeterminate="True" Visibility="{Binding IsConnecting, Converter={StaticResource myBooleanToVisibilityConverter}}"></ProgressBar>
        <Grid Grid.Row="1" Margin="2" IsEnabled="{Binding IsConnecting, Converter={StaticResource myBooleanReverserConverter}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="2*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Label Grid.Column="0" Grid.Row="0">DataSource :</Label>
            <TextBox Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Text="{Binding DataSource, Mode=TwoWay}"></TextBox>
            <Label Grid.Column="0" Grid.Row="1">Authentication :</Label>
            <RadioButton Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" IsChecked="{Binding IntegratedSecurity, Mode=TwoWay}">Windows Authentication
            </RadioButton>
            <RadioButton Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" x:Name="rdSqlAuth" IsChecked="{Binding IntegratedSecurity, Mode=TwoWay, Converter={StaticResource myBooleanReverserConverter}}">
                SQL Server Authentication
            </RadioButton>
            <Grid Grid.Column="1" Grid.Row="3" Grid.RowSpan="2" IsEnabled="{Binding ElementName=rdSqlAuth, Path=IsChecked}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="2*"/>
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" Grid.Row="0" >User Name</Label>
                <TextBox Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Text="{Binding User, Mode=TwoWay}"></TextBox>
                <Label Grid.Column="0" Grid.Row="1">Password</Label>
                <PasswordBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" my:PasswordBoxAssistant.BindPassword="true"  my:PasswordBoxAssistant.BoundPassword="{Binding Path=Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
        </Grid>
        <StackPanel Grid.Row="2" Orientation="Horizontal" FlowDirection="RightToLeft" Margin="0,0,5,5">
            <Button HorizontalAlignment="Right" Width="80" Margin="0,0,5,0" IsEnabled="{Binding IsConnecting}" IsDefault="{Binding IsConnecting}" Click="ConnectCancel_Click">Cancel</Button>
            <Button HorizontalAlignment="Right" Width="80" Click="Connect_Click" IsDefault="{Binding IsConnecting, Converter={StaticResource myBooleanReverserConverter}}" IsEnabled="{Binding IsConnecting, Converter={StaticResource myBooleanReverserConverter}}">Connect</Button>
        </StackPanel>
    </Grid>

</Window>
